package com.humanresource.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidateUtil {
	public static boolean isNull(String str) {
		if (str == null || str.length() <= 0) {
			return true;
		} else {
			return false;
		}
	}

	public static boolean isLengthRequired(int minLength, int maxLength,
			String str) {
		if (str.length() >= minLength && str.length() <= maxLength) {
			return true;
		} else {
			return false;
		}
	}

	/** 
	 * 此方法检查email有效性 返回提示信息 
	 * 
	 * @param email 
	 * @return 
	 */
	public static boolean checkEmail(String email) {
		// 电子邮件
		String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
		Pattern regex = Pattern.compile(check);
		Matcher matcher = regex.matcher(email);
		boolean isMatched = matcher.matches();
		return isMatched;
	}
}
